package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.annotation.WebUsed;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.TeaOilCardRecord;
import com.xinhe.web.response.TeaOilCardRecordView;
import com.xinhe.web.service.TeaOilCardRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "茶油卡兑换记录", tags = {"茶油卡兑换记录"})
@RestController
@RequestMapping(value = {"/teaOilCardRecord"}, produces = {"application/json;charset=UTF-8"})

public class TeaOilCardRecordController {

    @Autowired
    private TeaOilCardRecordService teaOilCardRecordService;

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "分页查询茶油卡兑换记录")
    @RequestMapping({"/pageTeaOilCardRecord"})
    public QueryResults<TeaOilCardRecordView> pageTeaOilCardRecord(String queryWord, String status,
                                                                   int pageNum, int pageSize) {
        return teaOilCardRecordService.pageTeaOilCardRecord(queryWord,status,pageNum,pageSize);
    }
    @ApiOperation(httpMethod = "POST", value = "兑换茶油卡审核")
    @RequestMapping({"/saveCheck"})
    public Result saveCheck(List<Long> ids, String result,String remark) {
        return teaOilCardRecordService.saveCheck(ids, result,remark);
    }
    //认养一棵树就送你4瓶茶油卡，这里兑换是指领取茶油。app端操作的
    //这个逻辑是这样的，我一提交兑换茶油卡，那么立马就会扣除我的茶油卡数量，如果说后台点击拒绝，那么这个数量再再回归的。
    @ApiOperation(httpMethod = "POST", value = "保存茶油卡兑换记录")
    @RequestMapping({"/saveTeaOilCardRecord"})//"领取方式 0线下 1快递配送
    public Result saveTeaOilCardRecord(Integer number,Integer type,Long userId) {
        return this.teaOilCardRecordService.saveTeaOilCardRecord(number,type,userId);
    }

    @ApiOperation(httpMethod = "GET", value = "删除茶油卡兑换记录")
    @ApiImplicitParam(name = "teaOilCardRecordId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteTeaOilCardRecord"})
    public Result deleteTeaOilCardRecord(Long teaOilCardRecordId) {
        return this.teaOilCardRecordService.delete(teaOilCardRecordId);
    }
    @ApiOperation(httpMethod = "GET", value = "茶油卡兑换记录详情")
    @ApiImplicitParam(name = "teaOilCardRecordId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailTeaOilCardRecord"})
    public Result detailTeaOilCardRecord(Long teaOilCardRecordId) {
        return this.teaOilCardRecordService.findById(teaOilCardRecordId);
    }

}
